//
//  registerViewController.swift
//  groupTaskTwo
//
//  Created by 向银泉 on 16/11/3.
//  Copyright © 2016年 向银泉. All rights reserved.
//

import UIKit

class registerViewController: UIViewController {
var sendValue:((String)->Void)? = nil
    @IBOutlet weak var coverImageView: UIImageView!
    
    @IBOutlet weak var nameLabel: UILabel!
    
    @IBOutlet weak var passWordLabel: UILabel!
    
    @IBOutlet weak var reconfigerLabel: UILabel!
    
    @IBOutlet weak var nametextField: UITextField!
    
    @IBOutlet weak var passwordField: UITextField!
    
    @IBOutlet weak var retextField: UITextField!
    
    @IBOutlet weak var registerbtn: UIButton!
    @IBAction func registerAction(sender: AnyObject) {
        if (self.nametextField.text?.characters.count == 0){
            KVNProgress.showErrorWithStatus("帐号不能位空")
            return
        }
        if self.passwordField.text?.characters.count == 0{
            KVNProgress.showErrorWithStatus("密码不能为空")
            return
        }
        if self.passwordField.text != self.retextField.text{
            KVNProgress.showErrorWithStatus("两次输入的密码不一致")
            return
        }
        
        KVNProgress.showWithStatus("正在注册")
        
        toolManager.BmobUserRegister(self.nametextField.text!, passWord: self.passwordField.text!) { (ret, message) in
            if ret{
                KVNProgress.showSuccessWithStatus(message)
                self.sendValue?(self.nametextField.text!)
            self.navigationController?.popViewControllerAnimated(true)
            }else{
                KVNProgress.showErrorWithStatus(message)
            }
        }
 
        
        
        
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        registerbtn.layer.masksToBounds = true
        registerbtn.layer.cornerRadius = 10
     
    }

    
}
